//
//  HttpHomeManager.m
//  Cat
//
//  Created by lushitong on 2018/12/19.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "HttpHomeManager.h"
#import "HttpHomePtl.h"

@implementation HttpHomeManager

+ (void)getHomeInfoWithSuccess:(void (^)(HomePriorityInfo *))success failure:(FLFailure)failure {
	[HttpHomePtl getHomeInfoWithSuccuss:^(NSDictionary * _Nonnull dict) {
		HomePriorityInfo *model = [HomePriorityInfo yy_modelWithDictionary:dict];
		if (success) {
			success(model);
		}
	} failure:failure];
}

+ (void)getSearchWithSuccess:(void (^)(SearchInfo *))success failure:(FLFailure)failure {
	[HttpHomePtl getSearchWithSuccuss:^(NSDictionary * _Nonnull dict) {
		SearchInfo *mode = [SearchInfo yy_modelWithDictionary:dict];
		if (success) {
			success(mode);
		}
	} failure:failure];
}

+ (void)searchWithKeyWord:(NSString *)keyWord andIndex:(NSNumber *)index withSuccess:(void (^)(NSArray *itemArray))success failure:(FLFailure)failure {
	[HttpHomePtl searchWithKeyWord:keyWord andIndex:index withSuccess:^(NSDictionary * _Nonnull dict) {
		NSArray *array = [NSArray yy_modelArrayWithClass:[GroomsModel class] json:dict];
		if (success) {
			success(array);
		}
	} failure:failure];
}

+ (void)getProductId:(NSNumber *)productID withSuccess:(void (^)(ProductInfo *ProductModel))success failure:(FLFailure)failure {
	[HttpHomePtl getProductId:productID WithSuccuss:^(NSDictionary * _Nonnull dict) {
		ProductInfo *model = [ProductInfo yy_modelWithDictionary:dict];
		if (success) {
			success(model);
		}
	} failure:failure];
}

+ (void)getShareCouponWithProductId:(NSNumber *)productID withSuccess:(void (^)(CouponInfo *couponModel))success failure:(FLFailure)failure {
	[HttpHomePtl getCouponWithProductId:productID WithSuccuss:^(NSDictionary * _Nonnull dict) {
		CouponInfo *model = [CouponInfo yy_modelWithDictionary:dict];
		if (success) {
			success(model);
		}
	} failure:failure];
}

+ (void)getShareInfoWithProductId:(NSNumber *)productID withSuccess:(void (^)(ShareCouponInfo *shareCouponModel))success failure:(FLFailure)failure {
	[HttpHomePtl getShareInfoProductId:productID WithSuccuss:^(NSDictionary * _Nonnull dict) {
		ShareCouponInfo *model = [ShareCouponInfo yy_modelWithDictionary:dict];
		if (success) {
			success(model);
		}
	} failure:failure];
}

+ (void)getIndexWithIndex:(NSNumber *)index success:(void (^)(NSArray *))success failure:(FLFailure)failure {
	[HttpHomePtl getIndexWithIndex:index WithSuccuss:^(NSDictionary *dict) {
		NSArray *array = [NSArray yy_modelArrayWithClass:[GroomsModel class] json:dict];
		if (success) {
			success(array);
		}
	} failure:failure];
}

+ (void)authGetinfoSuccess:(void (^)(NSString *authString))success failure:(FLFailure)failure {
    [HttpHomePtl authGetinfoSuccuss:^(NSDictionary *dict) {
        if (success) {
            success(dict[@"url"]);
        }
    } failure:failure];
}
@end
